# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=torcrawl
pkgver=142.43369ad
pkgrel=1
pkgdesc='Crawl and extract (regular or onion) webpages through TOR network.'
arch=('any')
groups=('blackarch' 'blackarch-webapp' 'blackarch-scanner')
url='https://github.com/MikeMeliz/TorCrawl.py'
license=('GPL3')
depends=('python' 'python-argparse' 'python-beautifulsoup4' 'python-requests'
         'python-socks' 'python-urllib3' 'python-yara-python-dex' 'tor')
makedepends=('git')
source=("$pkgname::git+https://github.com/MikeMeliz/TorCrawl.py.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname" README.md
  install -Dm 644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE

  rm requirements.txt README.md LICENSE

  cp -a --no-preserve=ownership * "$pkgdir/usr/share/$pkgname"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python $pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

